package org.eliza.base.basicx.functionx

private fun basic() {

    val total = "mississippi".count()
    val totalS = "mississippi".count { letter -> // 匿名函数
        letter == 's'
    }

    var aa: () -> Unit = fun() {
        1 // 不会返回
    }
    var bb: (ok: Boolean) -> Int = { it ->
        1 // 默认返回
    }
    //匿名参数
    var cc: (String, Int) -> Int = { name, age ->
        1
    }
    var dd: (name: String, age: Int) -> Int = { name, age ->
        1
    }
    val ee = { name: String, age: Int ->
        // 匿名 函数的参数名和参数类型必须有.
        "$name:$age"
    }
    // 匿名返回一个匿名
    val ff = { name: String, age: Int ->
        // 匿名 函数的参数名和参数类型必须有.
        { ok: Int ->
            // 闭包
            age + ok
        }
    }
    val gg = { aa: () -> Unit ->
        aa()
    }
    gg() { //括号可以省略

    }
}